home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Tool Chest / Testing & Debugging / Debuggers & dcmds / MacsBug 6.6 / Building dcmds / dcmd Includes / Dcmd.p < prev    next >
Encoding:
Text File  |  1999-10-20  |  8.3 KB  |  260 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        dcmd.p
  3.  
  4.      Contains:    MacsBug debugger command interface.
  5.  
  6.      Version:    Technology:    MacsBug
  7.                  Release:    MacsBug 6.6
  8.  
  9.      Copyright:    © 1988, 1994-1999, 1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT dcmd;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __DCMD__}
  27. {$SETC __DCMD__ := 1}
  28.  
  29. {$I+}
  30. {$SETC dcmdIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __MACHINEEXCEPTIONS__}
  37. {$I MachineExceptions.p}
  38. {$ENDC}
  39.  
  40.  
  41. {$PUSH}
  42. {$ALIGN MAC68K}
  43. {$LibExport+}
  44.  
  45. {  Possible requests from the debugger to the command }
  46.  
  47. CONST
  48.     dcmdInit                    = 0;                            {  Initialize the Dcmd  }
  49.     dcmdDoIt                    = 1;                            {  Normal Dcmd execution  }
  50.     dcmdHelp                    = 2;                            {  Display help for Dcmd  }
  51.                                                                 {  Requests added to MacsBug in 6.5d10 that are only sent to format 3 or newer dcmds.  }
  52.     dcmdSecondaryInit            = 3;                            {  Second time to init after all System patches have been loaded  }
  53.     dcmdShutdown                = 4;                            {  Dcmd should remove any patches (if possible)  }
  54.     dcmdGetInfo                    = 5;                            {  Return dcmd version and pointer to help text  }
  55.  
  56.  
  57. {  68K register file indices into the RegisterFile. }
  58.     D0Register                    = 0;
  59.     D1Register                    = 1;
  60.     D2Register                    = 2;
  61.     D3Register                    = 3;
  62.     D4Register                    = 4;
  63.     D5Register                    = 5;
  64.     D6Register                    = 6;
  65.     D7Register                    = 7;
  66.     A0Register                    = 8;
  67.     A1Register                    = 9;
  68.     A2Register                    = 10;
  69.     A3Register                    = 11;
  70.     A4Register                    = 12;
  71.     A5Register                    = 13;
  72.     A6Register                    = 14;
  73.     A7Register                    = 15;
  74.     PCRegister                    = 16;
  75.     SRRegister                    = 17;                            {  SR is only 16 bits and is stored in the high word  }
  76.  
  77.  
  78. {  Heap block types }
  79.     freeBlock                    = 0;
  80.     nonrelocatableBlock            = 1;
  81.     relocatableBlock            = 2;
  82.  
  83.  
  84. {     The format of the 68K registers passed to the dcmd. }
  85.  
  86. TYPE
  87.     RegisterFile                        = ARRAY [0..17] OF UInt32;
  88.     RegisterFilePtr                        = ^RegisterFile;
  89.  
  90. {  Structure used to pass information to and from the dcmd. }
  91.     dcmdBlockPtr = ^dcmdBlock;
  92.     dcmdBlock = PACKED RECORD
  93.         registerFile:            RegisterFilePtr;                        {  pointer to 68K CPU register set  }
  94.         request:                INTEGER;                                {  what action we are requested to take  }
  95.         aborted:                BOOLEAN;                                {  Set to true if the user types a key while scrolling  }
  96.         pad1:                    BOOLEAN;                                {  align to word boundary  }
  97.         macsBugVersion:            UInt32;                                    {  version of MacsBug we are running under  }
  98.         maxCallback:            UInt16;                                    {  maximum valid callback we can make  }
  99.         currentISA:                UInt8;                                    {  ISA of current PC  }
  100.         pad2:                    UInt8;                                    {  align to word boundary  }
  101.         theException:            ExceptionInformationPowerPCPtr;            {  Pointer to PowerPC machine state if ISA is PowerPC  }
  102.         requestIOBlock:            Ptr;                                    {  general-purpose input/output data block pointer  }
  103.     END;
  104.  
  105.  
  106.     GetInfoRequestBlockPtr = ^GetInfoRequestBlock;
  107.     GetInfoRequestBlock = RECORD
  108.         usageStr:                Str255;
  109.         creditsStr:                Str255;
  110.         dcmdVersion:            NumVersion;
  111.     END;
  112.  
  113.  
  114. {
  115.     MacsBug callback routines that can be called by the dcmd.
  116.  }
  117.  
  118. {
  119.     Draw the text in the Pascal string as one or more lines separated by CR's.
  120.     Each line causes the MacsBug display to be scrolled and the new line to be
  121.     drawn at the bottom. If the user types a key while scrolling then the aborted
  122.     flag is set telling the command to terminate immediately.
  123.  }
  124. PROCEDURE dcmdDrawLine(str: Str255);
  125.  
  126. {
  127.     Draw the text in the Pascal string as a continuation of the current line.
  128.     CR's are not given special treatment.
  129.  }
  130. PROCEDURE dcmdDrawString(str: Str255);
  131.  
  132. {
  133.     Draw a given number of characters starting from the given pointer as a 
  134.     continuation of the current line. CR's are not given special treatment.
  135.  }
  136. PROCEDURE dcmdDrawText(text: CStringPtr; length: INTEGER);
  137.  
  138. {
  139.     Scrolls the MacsBug display up one line leaving a blank line at the bottom.
  140.  }
  141. PROCEDURE dcmdScroll;
  142.  
  143. {
  144.     Display the Pascal string in the command line area and wait for a key to be pressed.
  145.     Return TRUE if the user typed Return. All other keys return FALSE. MacsBug saves this
  146.     key and adds it to the command line once the current command completes. Typing any
  147.     key other than Return sets the aborted flag and tells the command to terminate immediately.
  148.  }
  149. FUNCTION dcmdDrawPrompt(str: Str255): BOOLEAN;
  150.  
  151. {
  152.     Get the current command line position.
  153.  }
  154. FUNCTION dcmdGetPosition: INTEGER;
  155.  
  156. {
  157.     Set the current command line position. This should only be set to a value returned 
  158.     by dcmdGetPosition.
  159.  }
  160. PROCEDURE dcmdSetPosition(pos: INTEGER);
  161.  
  162. {
  163.     Return the next character on the command line or CR if the entire line has been scanned
  164.  }
  165. FUNCTION dcmdGetNextChar: INTEGER;
  166.  
  167. {
  168.     Return the next character on the command line or CR if the entire line has been scanned.
  169.     However, the current command line position is not changed.
  170.  }
  171. FUNCTION dcmdPeekAtNextChar: INTEGER;
  172.  
  173. {
  174.     Copy all characters from the command line to the parameter string until a delimiter
  175.     is found or the end of the command line is reached. A delimiter is either a space,
  176.     a comma or a CR. Both single and double quoted strings are allowed on the command
  177.     line. However, the leading and trailing quotes must be of the same type. The parameter
  178.     string is returned without the quotes. This function returns the delimiter.
  179.  }
  180. FUNCTION dcmdGetNextParameter(VAR str: Str255): INTEGER;
  181.  
  182. {
  183.     Parse the command line for the next expression. All expressions are evaluated to 32 bits.
  184.     This function returns the delimiter after the expression. The possible delimiters are
  185.     space, comma and CR. Space is not treated as a delimiter in the middle of expressions,
  186.     unless it's before a binary '-' (minus). For instance, '1 + 2' will return a value of 3
  187.     and the delimiter will be the char following the 2. '1 - 2' will return a value of 1
  188.     and the delimeter is the space character before the '-'. This is done so that built-in
  189.     commands and dcmds can properly parse '-x' options. The return parameter 'ok' tells if
  190.     the expression was parsed successfully as far as syntax is concerned.
  191.  }
  192. FUNCTION dcmdGetNextExpression(VAR value: LONGINT; VAR ok: BOOLEAN): INTEGER;
  193.  
  194. {
  195.     Copy the break message MacsBug displayed the last time it was entered into str.
  196.     This may contain multiple lines separated by CR's.
  197.  }
  198. PROCEDURE dcmdGetBreakMessage(VAR str: Str255);
  199.  
  200. {
  201.     Return a symbolic representation for address in str. If no symbol can be found
  202.     then an empty string is returned. The format of the symbol returned is Name+00000.
  203.  }
  204. PROCEDURE dcmdGetNameAndOffset(address: LONGINT; VAR str: Str255);
  205.  
  206. {
  207.     Return the trap name for the trap number. If no symbol can be found
  208.     then an empty string is returned.
  209.  }
  210. PROCEDURE dcmdGetTrapName(trapNumber: INTEGER; VAR trapName: Str255);
  211.  
  212. {
  213.     Return a pointer the macro name for the given value. If no macro can be found
  214.     then a nil is returned.
  215.  }
  216. FUNCTION dcmdGetMacroName(value: LONGINT): StringPtr;
  217.  
  218. {
  219.     When a debugger command is called, the debugger's world (low memory) is installed.
  220.     Commands that want to reference the user's world can swap back and forth between the
  221.     two worlds by making this call. This procedure does nothing in MacsBug; there is no
  222.     distinction between user and debugger worlds. It is included to support other
  223.     debuggers that might want to take advantage of it.
  224.  }
  225. PROCEDURE dcmdSwapWorlds;
  226.  
  227. {
  228.     Toggle between the user and debugger displays. The first call restores the user's actual screen.
  229.     The second call restores the debugger's screen.
  230.  }
  231. PROCEDURE dcmdSwapScreens;
  232.  
  233. {
  234.     Walk through the blocks in the current heap, calling DoThis for each block.
  235.     The blockAddress and blockLength pertain to the data in the heap block, not including
  236.     the block header. The addrOfMasterPtr is the master pointer's location in the heap,
  237.     not the value of the master ptr. The blockType is defined by the constants freeBlock,
  238.     nonrelocatableBlock and relocatableBlock. The booleans locked, purgeable and resource
  239.     reflect the state of the block.
  240.  }
  241.  
  242. TYPE
  243. {$IFC TYPED_FUNCTION_POINTERS}
  244.     DoThisPtr = PROCEDURE(blockAddress: LONGINT; blockLength: LONGINT; addrOfMasterPtr: LONGINT; blockType: INTEGER; locked: BOOLEAN; purgeable: BOOLEAN; resource: BOOLEAN);
  245. {$ELSEC}
  246.     DoThisPtr = ProcPtr;
  247. {$ENDC}
  248.  
  249. PROCEDURE dcmdForAllHeapBlocks(DoThis: DoThisPtr);
  250. {$ALIGN RESET}
  251. {$POP}
  252.  
  253. {$SETC UsingIncludes := dcmdIncludes}
  254.  
  255. {$ENDC} {__DCMD__}
  256.  
  257. {$IFC NOT UsingIncludes}
  258.  END.
  259. {$ENDC}
  260.